﻿using System;
using System.Drawing;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.ADF.CATIDs;
using ESRI.ArcGIS.Carto;
using DevComponents.DotNetBar;

namespace GISSystem.TocMenu
{
    /// <summary>
    /// Summary description for LayerSetting.
    /// </summary>
    [Guid("338f09fb-3ace-455d-9b66-139971359509")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("GISSystem.TocMenu.LayerSetting")]
    public sealed class CmdLayerSetting : BaseCommand
    {
        IFeatureLayer pSelectLayer;

        public CmdLayerSetting(IFeatureLayer layer)
        {
            //
            // TODO: Define values for the public properties
            //
            base.m_category = "TOCMenu"; //localizable text
            base.m_caption = "图层显示设置";  //localizable text
            base.m_message = "设置图层的显示样式";  //localizable text 
            base.m_toolTip = "设置图层的显示样式";  //localizable text 
            base.m_name = "TOCMenu_LayerSetting";   //unique id, non-localizable (e.g. "MyCategory_MyCommand")

            if (layer == null)
            {
                throw new Exception("此图层不是符合条件的图层。");
            }

            pSelectLayer = layer;

            try
            {
                //
                // TODO: change bitmap name if necessary
                //
                string bitmapResourceName = GetType().Name + ".bmp";
                base.m_bitmap = new Bitmap(GetType(), bitmapResourceName);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap");
            }
        }

        #region Overriden Class Methods

        /// <summary>
        /// Occurs when this command is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            // TODO:  Add LayerSetting.OnCreate implementation
        }

        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add LayerSetting.OnClick implementation
            MessageBoxEx.Show(pSelectLayer.Name);
        }

        #endregion
    }
}
